package com.michaelbulava.TFS.vcs.internal.conflicts;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.update.UpdatedFiles;
import com.microsoft.tfs.core.clients.versioncontrol.soapextensions.Conflict;
import com.microsoft.tfs.core.clients.versioncontrol.soapextensions.Workspace;
import com.microsoft.tfs.util.Check;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by MichaelA on 8/10/2015.
 */
public class ResolveConflictHelper {

    private final Project project;
    private final UpdatedFiles updatedFiles;
    private final Map<Conflict, Workspace> conflictWorkspaceMap = new HashMap<>();

    public ResolveConflictHelper(Project project, Map<Workspace, Conflict[]> workspace2Conflicts,
                                 UpdatedFiles updatedFiles){
        Check.notNull(project, "project");
        Check.notNull(workspace2Conflicts, "workspace2Conflicts");
        Check.notNull(updatedFiles, "updatedFiles");
        this.project = project;
        this.updatedFiles = updatedFiles;
        for(Map.Entry<Workspace, Conflict[]> item : workspace2Conflicts.entrySet()){
            for(Conflict conflict : item.getValue()){
                conflictWorkspaceMap.put(conflict, item.getKey());
            }
        }
    }

    public Collection<Conflict> getConflicts(){
        return Collections.unmodifiableCollection(this.conflictWorkspaceMap.keySet());
    }

}
